package org.apache.dubbo.rpc.cluster;

import org.apache.dubbo.rpc.model.ScopeModel;
import org.apache.dubbo.rpc.model.ScopeModelUtil;

public class ConfiguratorFactory$Adaptive implements org.apache.dubbo.rpc.cluster.ConfiguratorFactory {
    public org.apache.dubbo.rpc.cluster.Configurator getConfigurator(org.apache.dubbo.common.URL url) {
        String extName = url.getProtocol();
        if (extName == null)
            throw new IllegalStateException("Failed to get extension (org.apache.dubbo.rpc.cluster.ConfiguratorFactory) name from url (" + url.toString() + ") use keys([protocol])");

        ScopeModel scopeModel = ScopeModelUtil.getOrDefault(url.getScopeModel(),
                org.apache.dubbo.rpc.cluster.ConfiguratorFactory.class);
        org.apache.dubbo.rpc.cluster.ConfiguratorFactory extension =
                (org.apache.dubbo.rpc.cluster.ConfiguratorFactory)
                        scopeModel.getExtensionLoader(org.apache.dubbo.rpc.cluster.ConfiguratorFactory.class)
                                .getExtension(extName);

        return extension.getConfigurator(url);
    }
}
